package com.noble.glamour.bean.center.user.detail;

import android.os.Parcel;

import com.noble.library.utils.StringUtils;

import org.json.JSONObject;

/**
 * 用户详细信息
 */
public class UserDetail extends UserBasic {
    private int isVip;          // -1 未开通    1： 开通   2： 永久开通
    private String vipEndTime;      // VIP结束时间
    private double star;             // 女性评分
    private double amountStar;       // 女性评分收益率
    private int doPay;              // 充值钻石
    private int doGive;             // 赠送钻石
    private int diamand;            // 我的钻石

    private double amountCash;     // 聊天可提现金额： 单位：元
    private double amountInvite;     // 邀请收益金额

    private String alipay;          // 用户支付宝账户
    private String realName;        // 用户真实姓名

    private int numFriendAsk;       // 好友申请数据
    private int statusAuth;         // 女性： 认证状态  -3：未认证 -2：申请认证 -1：未通过 1：通过认证

    @Override
    public void parseJson(String s) {
        super.parseJson(s);   // 基本信息解析

        JSONObject detailObject = getJsonObject(s);
        this.setVip(detailObject.optInt("IsVip"));
        this.setVipEndTime(detailObject.optString("TimeEndVip"));
        this.setDoPay(detailObject.optInt("DoPay"));
        this.setDoGive(detailObject.optInt("DoGive"));
        this.setDiamand(getDoGive() + getDoPay());
        this.setStar(detailObject.optDouble("Star"));
        this.setAmountStar(detailObject.optDouble("AmountStar"));

        this.setAmountCash(detailObject.optDouble("AmountChat"));
        this.setAmountInvite(detailObject.optDouble("AmountInvite"));
        this.setAlipay(detailObject.optString("Alipay"));
        this.setRealName(detailObject.optString("RealName"));

        this.setNumFriendAsk(detailObject.optInt("NumFriendAsk"));
        this.setStatusAuth(detailObject.optInt("StatusAuth"));
    }

    /**
     * 判断是否是vip
     */
    public boolean isVip() {
        return isVip == 1 || isVip == 2;
    }

    public int getIsVip() {
        return isVip;
    }

    /**
     * @return 是否永久vip
     */
    public boolean isForEverVip() {
        return isVip == 2;
    }

    public String getVipEndTime() {
        return StringUtils.getCreateTime(vipEndTime);
    }

    /**
     * @return 是否通过认证
     */
    public boolean isPassAuth() {
        return statusAuth >= 1;
    }

    /**
     * @return 女性用户是否可以聊天：
     */
    public boolean isCanChat() {
        return statusAuth == 1 || statusAuth == -2;
    }

    public double getAmountStar() {
        return amountStar;
    }

    public void setAmountStar(double amountStar) {
        this.amountStar = amountStar;
    }

    public int getStatusAuth() {
        return statusAuth;
    }

    public void setStatusAuth(int statusAuth) {
        this.statusAuth = statusAuth;
    }

    public int getNumFriendAsk() {
        return numFriendAsk;
    }

    public void setNumFriendAsk(int numFriendAsk) {
        this.numFriendAsk = numFriendAsk;
    }

    public int getDoPay() {
        return doPay;
    }

    public void setDoPay(int doPay) {
        this.doPay = doPay;
    }

    public int getDoGive() {
        return doGive;
    }

    public void setDoGive(int doGive) {
        this.doGive = doGive;
    }

    public double getStar() {
        return star;
    }

    public void setStar(double star) {
        this.star = star;
    }

    public String getAlipay() {
        return alipay;
    }

    public void setAlipay(String alipay) {
        this.alipay = alipay;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public double getAmountInvite() {
        return amountInvite;
    }

    public void setAmountInvite(double amountInvite) {
        this.amountInvite = amountInvite;
    }

    public double getAmountCash() {
        return amountCash;
    }

    public void setAmountCash(double amountCash) {
        this.amountCash = amountCash;
    }

    public void setVipEndTime(String vipEndTime) {
        this.vipEndTime = vipEndTime;
    }

    public void setVip(int vip) {
        isVip = vip;
    }

    public int getDiamand() {
        return diamand;
    }

    public void setDiamand(int diamand) {
        this.diamand = diamand;
    }

    public UserDetail() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        super.writeToParcel(dest, flags);
        dest.writeInt(this.isVip);
        dest.writeString(this.vipEndTime);
        dest.writeDouble(this.star);
        dest.writeDouble(this.amountStar);
        dest.writeInt(this.doPay);
        dest.writeInt(this.doGive);
        dest.writeInt(this.diamand);
        dest.writeDouble(this.amountCash);
        dest.writeDouble(this.amountInvite);
        dest.writeString(this.alipay);
        dest.writeString(this.realName);
        dest.writeInt(this.numFriendAsk);
        dest.writeInt(this.statusAuth);
    }

    protected UserDetail(Parcel in) {
        super(in);
        this.isVip = in.readInt();
        this.vipEndTime = in.readString();
        this.star = in.readDouble();
        this.amountStar = in.readDouble();
        this.doPay = in.readInt();
        this.doGive = in.readInt();
        this.diamand = in.readInt();
        this.amountCash = in.readDouble();
        this.amountInvite = in.readDouble();
        this.alipay = in.readString();
        this.realName = in.readString();
        this.numFriendAsk = in.readInt();
        this.statusAuth = in.readInt();
    }

    public static final Creator<UserDetail> CREATOR = new Creator<UserDetail>() {
        @Override
        public UserDetail createFromParcel(Parcel source) {
            return new UserDetail(source);
        }

        @Override
        public UserDetail[] newArray(int size) {
            return new UserDetail[size];
        }
    };
}
